;Assembler header file for Socket
;written by DefMod (Dec 31 2005) on Sat Dec 31 14:01:39 2005
;Jonathan Coxhead, jonathan@doves.demon.co.uk, 22 Aug 1995

        [       :LNOT: :DEF: Socket_Hdr
        GBLS    Socket_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

;Symbols for constants
Socket_AFInet                   *       &2
Socket_SockStream               *       &1
Socket_SockDGram                *       &2
Socket_SockRaw                  *       &3
Socket_IpprotoIP                *       &0
Socket_IpprotoICMP              *       &1
Socket_IpprotoTCP               *       &6
Socket_IpprotoUDP               *       &11
Socket_IpprotoRaw               *       &FF
Socket_SolSocket                *       &FFFF
Socket_EBadf                    *       &9
Socket_EAgain                   *       &B
Socket_EFault                   *       &E
Socket_EInval                   *       &16
Socket_EWouldblock              *       &23
Socket_EInprogress              *       &24
Socket_EAlready                 *       &25
Socket_ENotsock                 *       &26
Socket_EDestaddrreq             *       &27
Socket_EMsgsize                 *       &28
Socket_EPrototype               *       &29
Socket_ENoprotoopt              *       &2A
Socket_EProtonosupport          *       &2B
Socket_ESocktnosupport          *       &2C
Socket_EOpnotsupp               *       &2D
Socket_EPfnosupport             *       &2E
Socket_EAfnosupport             *       &2F
Socket_EAddrinuse               *       &30
Socket_EAddrnotavail            *       &31
Socket_ENetdown                 *       &32
Socket_ENetunreach              *       &33
Socket_ENetreset                *       &34
Socket_EConnaborted             *       &35
Socket_EConnreset               *       &36
Socket_ENobufs                  *       &37
Socket_EIsconn                  *       &38
Socket_ENotconn                 *       &39
Socket_EShutdown                *       &3A
Socket_EToomanyrefs             *       &3B
Socket_ETimedout                *       &3C
Socket_EConnrefused             *       &3D
Socket_EHostdown                *       &40
Socket_EHostunreach             *       &41
Socket_SoAcceptconn             *       &2
Socket_SoReuseaddr              *       &4
Socket_SoKeepalive              *       &8
Socket_SoDontroute              *       &10
Socket_SoBroadcast              *       &20
Socket_SoUseloopback            *       &40
Socket_SoLinger                 *       &80
Socket_SoOobinline              *       &100
Socket_SoSndbuf                 *       &1001
Socket_SoRcvbuf                 *       &1002
Socket_SoSndlowat               *       &1003
Socket_SoRcvlowat               *       &1004
Socket_SoSndtimeo               *       &1005
Socket_SoRcvtimeo               *       &1006
Socket_SoError                  *       &1007
Socket_SoType                   *       &1008
Socket_IFNameLimit              *       16
Socket_IFUp                     *       &1
Socket_IFBroadcast              *       &2
Socket_IFDebug                  *       &4
Socket_IFLoopback               *       &8
Socket_IFPointToPoint           *       &10
Socket_IFNoTrailers             *       &20
Socket_IFRunning                *       &40
Socket_IFNoARP                  *       &80
Socket_SIOCSHIWAT               *       &80047300
Socket_SIOCGHIWAT               *       &40047301
Socket_SIOCSLOWAT               *       &80047302
Socket_SIOCGLOWAT               *       &40047303
Socket_SIOCATMARK               *       &40047307
Socket_SIOCSIFADDR              *       &8020690C
Socket_SIOCGIFADDR              *       &C020690D
Socket_SIOCSIFDSTADDR           *       &8020690E
Socket_SIOCGIFDSTADDR           *       &C020690F
Socket_SIOCSIFFLAGS             *       &80206910
Socket_SIOCGIFFLAGS             *       &C0206911
Socket_SIOCGIFBRDADDR           *       &C0206912
Socket_SIOCSIFBRDADDR           *       &80206913
Socket_SIOCGIFCONF              *       &C0086914
Socket_SIOCGIFNETMASK           *       &C0206915
Socket_SIOCSIFNETMASK           *       &80206916
Socket_SIOCGIFMETRIC            *       &C0206917
Socket_SIOCSIFMETRIC            *       &80206918
Socket_FIOSLEEPTW               *       &80046679
Socket_FIONREAD                 *       &4004667F
Socket_FIONBIO                  *       &8004667E
Socket_FIOASYNC                 *       &8004667D
Socket_FIOPOLLWORD              *       &80086678
Socket_MsgOob                   *       &1
Socket_MsgPeek                  *       &2
Socket_MsgDontroute             *       &4
Socket_ShutdownRecv             *       &0
Socket_ShutdownSend             *       &1
Socket_ShutdownAll              *       &2
Socket_AsyncEvent               *       &1
Socket_UrgentEvent              *       &2
Socket_BrokenEvent              *       &3

;Symbols for structure offsets and sizes
                                ^       0
                                #       Short
Socket_AF                       *       @

                                ^       0
                                #       Int
Socket_Sock                     *       @

                                ^       0
                                #       Int
Socket_Ipproto                  *       @

                                ^       0
                                #       Int
Socket_Level                    *       @

                                ^       0
Socket_SockaddrIn_af            #       Socket_AF
Socket_SockaddrIn_port          #       Short
Socket_SockaddrIn_addr          #       Bits
Socket_SockaddrIn_data          #       8*Byte
Socket_SockaddrIn               *       @

                                ^       0
Socket_Sockaddr_sockaddr_af     #       Socket_AF
Socket_Sockaddr_sockaddr_data   #       14*Byte
                                ^       0
Socket_Sockaddr_sockaddr_in     #       Socket_SockaddrIn
Socket_Sockaddr                 *       @

                                ^       0
Socket_Linger_onoff             #       Int
Socket_Linger_linger            #       Int
Socket_Linger                   *       @

                                ^       0
Socket_Timeval_sec              #       Int
Socket_Timeval_usec             #       Int
Socket_Timeval                  *       @

                                ^       0
                                #       Int
Socket_So                       *       @

                                ^       0
                                #       Short
Socket_IFFlags                  *       @

                                ^       0
Socket_Ifreq_name               #       16*Char
Socket_Ifreq_u                  *       @
Socket_Ifreq_u_sockaddr         #       Socket_Sockaddr
                                ^       Socket_Ifreq_u
Socket_Ifreq_u_broadaddr        #       Socket_Sockaddr
                                ^       Socket_Ifreq_u
Socket_Ifreq_u_flags            #       Socket_IFFlags
                                ^       Socket_Ifreq_u
Socket_Ifreq_u_metric           #       Int
                                ^       Socket_Ifreq_u
Socket_Ifreq_u_data             #       Ptr
                                ^       Socket_Ifreq_u
Socket_Ifreq_u_reserved         #       16*Byte
Socket_Ifreq                    *       @

                                ^       0
Socket_Ifconf_len               #       Int
Socket_Ifconf_u                 *       @
Socket_Ifconf_u_buf             #       Ptr
                                ^       Socket_Ifconf_u
Socket_Ifconf_u_req             #       Ptr
Socket_Ifconf                   *       @

                                ^       0
Socket_Pwstruct_pollword        #       Ptr
Socket_Pwstruct_bit_number      #       Int
Socket_Pwstruct                 *       @

                                ^       0
                                #       Bits
Socket_IoctlNo                  *       @

                                ^       0
                                #       Bits
Socket_MsgFlags                 *       @

Socket_S                        *       4 ;abstract type
                                ^       0
Socket_Iovec_base               #       Ptr
Socket_Iovec_len                #       Int
Socket_Iovec                    *       @

                                ^       0
Socket_Msghdr_name              #       Ptr
Socket_Msghdr_namelen           #       Int
Socket_Msghdr_iov               #       Ptr
Socket_Msghdr_iov_count         #       Int
Socket_Msghdr_accrights         #       Ptr
Socket_Msghdr_accrightslen      #       Int
Socket_Msghdr                   *       @

                                ^       0
                                #       Int
Socket_ShutdownType             *       @

Socket_Fdset                    *       Skip

                                ^       0
                                #       Int
Socket_EventType                *       @


;Symbols for SWI's and SWI reason codes
XSocket_Creat                   *       &61200
Socket_Creat                    *       &41200
   ;Entry
   ;  R0 = af (Socket_AF)
   ;  R1 = sock (Socket_Sock)
   ;  R2 = proto (Socket_Ipproto)
   ;Exit
   ;  R0 = s (Socket_S)

XSocket_Bind                    *       &61201
Socket_Bind                     *       &41201
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 -> sockaddr (Socket_Sockaddr)
   ;  R2 = namelen (Int)

XSocket_Listen                  *       &61202
Socket_Listen                   *       &41202
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = backlog (Int)

XSocket_Accept                  *       &61203
Socket_Accept                   *       &41203
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = sockaddr (pointer to Socket_Sockaddr)
   ;  R2 = addrlen (pointer to Int)
   ;Exit
   ;  R0 = ns (Socket_S)

XSocket_Connect                 *       &61204
Socket_Connect                  *       &41204
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = sockaddr (pointer to Socket_Sockaddr)
   ;  R2 = namelen (Int)

XSocket_Recv                    *       &61205
Socket_Recv                     *       &41205
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = buf (pointer to data)
   ;  R2 = len (Int)
   ;  R3 = flags (Socket_MsgFlags)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Recvfrom                *       &61206
Socket_Recvfrom                 *       &41206
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = buf (pointer to data)
   ;  R2 = len (Int)
   ;  R3 = flags (Socket_MsgFlags)
   ;  R4 = from (pointer to Socket_Sockaddr)
   ;  R5 = fromlen (pointer to Int)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Recvmsg                 *       &61207
Socket_Recvmsg                  *       &41207
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = msg (pointer to Socket_Msghdr)
   ;  R2 = flags (Socket_MsgFlags)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Send                    *       &61208
Socket_Send                     *       &41208
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 -> msg (data)
   ;  R2 = len (Int)
   ;  R3 = flags (Socket_MsgFlags)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Sendto                  *       &61209
Socket_Sendto                   *       &41209
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 -> msg (data)
   ;  R2 = len (Int)
   ;  R3 = flags (Socket_MsgFlags)
   ;  R4 -> to (Socket_Sockaddr)
   ;  R5 = tolen (Int)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Sendmsg                 *       &6120A
Socket_Sendmsg                  *       &4120A
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 -> msg (Socket_Msghdr)
   ;  R2 = flags (Socket_MsgFlags)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Shutdown                *       &6120B
Socket_Shutdown                 *       &4120B
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = type (Socket_ShutdownType)

XSocket_Setsockopt              *       &6120C
Socket_Setsockopt               *       &4120C
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = level (Socket_Level)
   ;  R2 = optname (Socket_So)
   ;  R3 -> optval (data)
   ;  R4 = optlen (Int)

XSocket_Getsockopt              *       &6120D
Socket_Getsockopt               *       &4120D
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = level (Socket_Level)
   ;  R2 = optname (Socket_So)
   ;  R3 = optval (pointer to data)
   ;  R4 = optlen (pointer to Int)

XSocket_Getpeername             *       &6120E
Socket_Getpeername              *       &4120E
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = sockaddr (pointer to Socket_Sockaddr)
   ;  R2 = namelen (pointer to Int)

XSocket_Getsockname             *       &6120F
Socket_Getsockname              *       &4120F
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = sockaddr (pointer to Socket_Sockaddr)
   ;  R2 = namelen (pointer to Int)

XSocket_Close                   *       &61210
Socket_Close                    *       &41210
   ;Entry
   ;  R0 = s (Socket_S)

XSocket_Select                  *       &61211
Socket_Select                   *       &41211
   ;Entry
   ;  R0 = nfds (Int)
   ;  R1 -> readfds (Socket_Fdset)
   ;  R2 -> writefds (Socket_Fdset)
   ;  R3 -> exceptfds (Socket_Fdset)
   ;  R4 -> timeout (Socket_Timeval)
   ;Exit
   ;  R0 = nfound (Int)

XSocket_Ioctl                   *       &61212
Socket_Ioctl                    *       &41212
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = flags (Socket_IoctlNo)
   ;  R2 = argp (pointer to data)

XSocket_Read                    *       &61213
Socket_Read                     *       &41213
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = buf (pointer to data)
   ;  R2 = len (Int)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Write                   *       &61214
Socket_Write                    *       &41214
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 -> msg (data)
   ;  R2 = len (Int)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Stat                    *       &61215
Socket_Stat                     *       &41215

XSocket_Readv                   *       &61216
Socket_Readv                    *       &41216
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 = iov (pointer to Socket_Iovec)
   ;  R2 = iov_count (Int)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Writev                  *       &61217
Socket_Writev                   *       &41217
   ;Entry
   ;  R0 = s (Socket_S)
   ;  R1 -> iov (Socket_Iovec)
   ;  R2 = iov_count (Int)
   ;Exit
   ;  R0 = cc (Int)

XSocket_Gettsize                *       &61218
Socket_Gettsize                 *       &41218
   ;Exit
   ;  R0 = size (Int)

XSocket_Sendtosm                *       &61219
Socket_Sendtosm                 *       &41219

XSocket_Sysctl                  *       &6121A
Socket_Sysctl                   *       &4121A

XSocket_Accept_1                *       &6121B
Socket_Accept_1                 *       &4121B

XSocket_Recvfrom_1              *       &6121C
Socket_Recvfrom_1               *       &4121C

XSocket_Recvmsg_1               *       &6121D
Socket_Recvmsg_1                *       &4121D

XSocket_Sendmsg_1               *       &6121E
Socket_Sendmsg_1                *       &4121E

XSocket_Getpeername_1           *       &6121F
Socket_Getpeername_1            *       &4121F

XSocket_Getsockname_1           *       &61220
Socket_Getsockname_1            *       &41220

XSocket_InternalLookup          *       &61221
Socket_InternalLookup           *       &41221

XSocket_Version                 *       &61222
Socket_Version                  *       &41222
   ;Exit
   ;  R0 = n (Int)

Event_Internet                  *       &13
   ;Entry
   ;  R0 = &13
   ;  R1 = event_type (Socket_EventType)
   ;  R2 = s (Socket_S)

EventInternet_Async             *       &1
   ;Entry
   ;  R0 = &13
   ;  R1 = &1
   ;  R2 = s (Socket_S)

EventInternet_Urgent            *       &2
   ;Entry
   ;  R0 = &13
   ;  R1 = &2
   ;  R2 = s (Socket_S)

EventInternet_Broken            *       &3
   ;Entry
   ;  R0 = &13
   ;  R1 = &3
   ;  R2 = s (Socket_S)

EventInternet_RARPReply         *       &4
   ;Entry
   ;  R0 = &13
   ;  R1 = &4
   ;  R2 = addr (Bits)
   ;  R3 = req_addr (Bits)

        ]
        END
